﻿import "../Chart.js/chart.umd.min.js";

(function setFontSize() {
    Chart.defaults.font.size = 16;
})();

function pad(n, z) {
    z = z || 2;
    return ('0000' + n).slice(-z);
}

//sec in float.
export function toStopWatchTimeString(floatSec) {
    let v = Math.round(floatSec);
    //var ns = v % 1000;
    //v = (v - ns) / 1000;
    var sec = v % 60;
    v = (v - sec) / 60;
    var min = v % 60;
    var hr = (v - min) / 60;
    let dst = pad(hr) + ':'
        + pad(min, 2) + ':'
        + pad(sec, 2);
    //+ '.' + pad(ns, 3);
    //console.log(s);
    //console.log(dst);
    return dst;
}

//sec in float.
export function toStopWatchTimeDetailString(floatSec) {
    let v = Math.round(floatSec * 10000);
    var msp1 = v % 10000;
    v = (v - msp1) / 10000;
    var sec = v % 60;
    v = (v - sec) / 60;
    var min = v % 60;
    var hr = (v - min) / 60;
    let dst = pad(hr) + ':'
        + pad(min, 2) + ':'
        + pad(sec, 2)
        + '.' + pad(msp1, 4);
    return dst;
}